<?php

namespace app\common\model;

class Config extends Base
{
    /**
     * getAll
     * @return array
     * @throws
     */
    public function getAll(): array
    {
        $config = [];
        $configList = $this->select();
        foreach ($configList as $k => $v) {
            $value = $v->toArray();
            if (in_array($value['type'], ['selects', 'checkbox', 'images', 'files'])) {
                $value['value'] = explode(',', $value['value']);
            }
            if ($value['type'] == 'array') {
                $value['value'] = (array)json_decode($value['value'], true);
            }
            $config[$value['name']] = $value['value'];
        }
        return $config;
    }
}